﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using ThiefRun.States;

namespace ThiefRun.Graphics
{
    class HUD
    {
        #region Constants
        // Constants
        const int MINUTE = 60;
        const int TEXT_SEPERATION = 25;
        const int CHARACTER_WIDTH = 10;
        #endregion Constants

        #region Properties
        // Properties
        private ThiefRunGame game;
        private LevelState stage;
        private SpriteFont font;
        #endregion Properties

        #region Computed Properties
        // Computed Propertiess
        #endregion

        #region Methods
        // Methods

        /// <summary>
        /// Initialize the Level object.
        /// </summary>
        /// <param name="name">The level that will be loaded.</param>
        /// <param name="size">Provides the components of the size of the tile.</param>
        public HUD(ThiefRunGame game, LevelState stage)
        {
            this.stage = stage;
            font = game.Content.Load<SpriteFont>("Fonts/Hud");
        }

        /// <summary>
        /// Draw the HUD on the screen.
        /// </summary>
        /// <param name="gameTime">Provides access to the timer.</param>
        /// <param name="spriteBatch">Provides an object to a sprite.</param>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            string timeLimit = "Time Left: ";
            int seconds;
            string secondsStr = "";
            string minutes = ((int)(stage.TimeLeft) / MINUTE).ToString();
            string floor = "Floor: " + stage.currentLevel.CurrentFloor;
            Vector2 pos = Vector2.Zero;

            seconds = ((int)(stage.TimeLeft) % MINUTE);
            // Put a zero in front if necessary.
            if (seconds < 10)
                secondsStr += "0";
            secondsStr += seconds.ToString();

            timeLimit += minutes;
            timeLimit += ":";
            timeLimit += secondsStr;
            
           
            spriteBatch.Begin();
                spriteBatch.DrawString(font, timeLimit, pos, Color.Red);

                pos.X += TEXT_SEPERATION;
                pos.X += (CHARACTER_WIDTH * timeLimit.Length);
                spriteBatch.DrawString(font, floor, pos, Color.Red);
            spriteBatch.End();
        }
        #endregion Methods
    }
}
